<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QModelIndex Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QModelIndex Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QModelIndex class is used to locate data in a data model.
<a href="#details">More...</a></p>

<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qmodelindex.html#QModelIndex">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmodelindex.html#QModelIndex-2">__init__</a></b> (<i>self</i>, QModelIndex&#160;<i>other</i>)</li><li><div class="fn" /><b><a href="qmodelindex.html#QModelIndex-3">__init__</a></b> (<i>self</i>, QPersistentModelIndex)</li><li><div class="fn" />QModelIndex <b><a href="qmodelindex.html#child">child</a></b> (<i>self</i>, int&#160;<i>arow</i>, int&#160;<i>acolumn</i>)</li><li><div class="fn" />int <b><a href="qmodelindex.html#column">column</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qmodelindex.html#data">data</a></b> (<i>self</i>, int&#160;<i>role</i>&#160;=&#160;Qt.DisplayRole)</li><li><div class="fn" />Qt.ItemFlags <b><a href="qmodelindex.html#flags">flags</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qmodelindex.html#internalId">internalId</a></b> (<i>self</i>)</li><li><div class="fn" />object <b><a href="qmodelindex.html#internalPointer">internalPointer</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmodelindex.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />QAbstractItemModel <b><a href="qmodelindex.html#model">model</a></b> (<i>self</i>)</li><li><div class="fn" />QModelIndex <b><a href="qmodelindex.html#parent">parent</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qmodelindex.html#row">row</a></b> (<i>self</i>)</li><li><div class="fn" />QModelIndex <b><a href="qmodelindex.html#sibling">sibling</a></b> (<i>self</i>, int&#160;<i>arow</i>, int&#160;<i>acolumn</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qmodelindex.html#__eq__">__eq__</a></b> (<i>self</i>, QModelIndex&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qmodelindex.html#__ge__">__ge__</a></b> (<i>self</i>, QModelIndex&#160;<i>other</i>)</li><li><div class="fn" />int <b><a href="qmodelindex.html#__hash__">__hash__</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmodelindex.html#__lt__">__lt__</a></b> (<i>self</i>, QModelIndex&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qmodelindex.html#__ne__">__ne__</a></b> (<i>self</i>, QModelIndex&#160;<i>other</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QModelIndex class is used to locate data in a data
model.</p>
<p>This class is used as an index into item models derived from
<a href="qabstractitemmodel.html">QAbstractItemModel</a>. The index
is used by item views, delegates, and selection models to locate an
item in the model.</p>
<p>New QModelIndex objects are created by the model using the
<a href="qabstractitemmodel.html#createIndex">QAbstractItemModel.createIndex</a>()
function. An <i>invalid</i> model index can be constructed with the
QModelIndex constructor. Invalid indexes are often used as parent
indexes when referring to top-level items in a model.</p>
<p>Model indexes refer to items in models, and contain all the
information required to specify their locations in those models.
Each index is located in a given row and column, and may have a
parent index; use <a href="qmodelindex.html#row">row</a>(),
<a href="qmodelindex.html#column">column</a>(), and <a href="qmodelindex.html#parent">parent</a>() to obtain this information.
Each top-level item in a model is represented by a model index that
does not have a parent index - in this case, <a href="qmodelindex.html#parent">parent</a>() will return an invalid model
index, equivalent to an index constructed with the zero argument
form of the <a href="qmodelindex.html#QModelIndex">QModelIndex</a>() constructor.</p>
<p>To obtain a model index that refers to an existing item in a
model, call <a href="qabstractitemmodel.html#index">QAbstractItemModel.index</a>()
with the required row and column values, and the model index of the
parent. When referring to top-level items in a model, supply
<a href="qmodelindex.html#QModelIndex">QModelIndex</a>() as the
parent index.</p>
<p>The <a href="qmodelindex.html#model">model</a>() function
returns the model that the index references as a <a href="qabstractitemmodel.html">QAbstractItemModel</a>. The <a href="qmodelindex.html#child">child</a>() function is used to examine
items held under the index in the model. The <a href="qmodelindex.html#sibling">sibling</a>() function allows you to
traverse items in the model on the same level as the index.</p>
<p><b>Note:</b> Model indexes should be used immediately and then
discarded. You should not rely on indexes to remain valid after
calling model functions that change the structure of the model or
delete items. If you need to keep a model index over time use a
<a href="qpersistentmodelindex.html">QPersistentModelIndex</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QModelIndex" />QModelIndex.__init__ (<i>self</i>)</h3><p>Creates a new empty model index. This type of model index is
used to indicate that the position in the model is invalid.</p>
<p><b>See also</b> <a href="qmodelindex.html#isValid">isValid</a>()
and <a href="qabstractitemmodel.html">QAbstractItemModel</a>.</p>


<h3 class="fn"><a name="QModelIndex-2" />QModelIndex.__init__ (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>other</i>)</h3><p>Creates a new model index that is a copy of the <i>other</i>
model index.</p>


<h3 class="fn"><a name="QModelIndex-3" />QModelIndex.__init__ (<i>self</i>, <a href="qpersistentmodelindex.html">QPersistentModelIndex</a>)</h3><h3 class="fn"><a name="child" /><a href="qmodelindex.html">QModelIndex</a> QModelIndex.child (<i>self</i>, int&#160;<i>arow</i>, int&#160;<i>acolumn</i>)</h3><p>Returns the child of the model index that is stored in the given
<i>row</i> and <i>column</i>.</p>
<p><b>Note:</b> This function does not work for an invalid model
index which is often used as the root index.</p>
<p><b>See also</b> <a href="qmodelindex.html#parent">parent</a>()
and <a href="qmodelindex.html#sibling">sibling</a>().</p>


<h3 class="fn"><a name="column" />int QModelIndex.column (<i>self</i>)</h3><p>Returns the column this model index refers to.</p>


<h3 class="fn"><a name="data" />QVariant QModelIndex.data (<i>self</i>, int&#160;<i>role</i>&#160;=&#160;Qt.DisplayRole)</h3><p>Returns the data for the given <i>role</i> for the item referred
to by the index.</p>


<h3 class="fn"><a name="flags" /><a href="qt-itemflags.html">Qt.ItemFlags</a> QModelIndex.flags (<i>self</i>)</h3><p>Returns the flags for the item referred to by the index.</p>
<p>This function was introduced in Qt 4.2.</p>


<h3 class="fn"><a name="internalId" />int QModelIndex.internalId (<i>self</i>)</h3><p>Returns a <tt>long</tt> used by the model to associate the
index with the internal data structure.</p>
<p><b>See also</b> <a href="qabstractitemmodel.html#createIndex">QAbstractItemModel.createIndex</a>().</p>


<h3 class="fn"><a name="internalPointer" />object QModelIndex.internalPointer (<i>self</i>)</h3><p>Returns a <tt>void</tt> <tt>*</tt> pointer used by the model to
associate the index with the internal data structure.</p>
<p><b>See also</b> <a href="qabstractitemmodel.html#createIndex">QAbstractItemModel.createIndex</a>().</p>


<h3 class="fn"><a name="isValid" />bool QModelIndex.isValid (<i>self</i>)</h3><p>Returns true if this model index is valid; otherwise returns
false.</p>
<p>A valid index belongs to a model, and has non-negative row and
column numbers.</p>
<p><b>See also</b> <a href="qmodelindex.html#model">model</a>(),
<a href="qmodelindex.html#row">row</a>(), and <a href="qmodelindex.html#column">column</a>().</p>


<h3 class="fn"><a name="model" /><a href="qabstractitemmodel.html">QAbstractItemModel</a> QModelIndex.model (<i>self</i>)</h3><p>Returns a pointer to the model containing the item that this
index refers to.</p>
<p>A const pointer to the model is returned because calls to
non-const functions of the model might invalidate the model index
and possibly crash your application.</p>


<h3 class="fn"><a name="parent" /><a href="qmodelindex.html">QModelIndex</a> QModelIndex.parent (<i>self</i>)</h3><p>Returns the parent of the model index, or <a href="qmodelindex.html#QModelIndex">QModelIndex</a>() if it has no
parent.</p>
<p><b>See also</b> <a href="qmodelindex.html#child">child</a>(),
<a href="qmodelindex.html#sibling">sibling</a>(), and <a href="qmodelindex.html#model">model</a>().</p>


<h3 class="fn"><a name="row" />int QModelIndex.row (<i>self</i>)</h3><p>Returns the row this model index refers to.</p>


<h3 class="fn"><a name="sibling" /><a href="qmodelindex.html">QModelIndex</a> QModelIndex.sibling (<i>self</i>, int&#160;<i>arow</i>, int&#160;<i>acolumn</i>)</h3><p>Returns the sibling at <i>row</i> and <i>column</i>. If there is
no sibling at this position, an invalid <a href="qmodelindex.html">QModelIndex</a> is returned.</p>
<p><b>See also</b> <a href="qmodelindex.html#parent">parent</a>()
and <a href="qmodelindex.html#child">child</a>().</p>


<h3 class="fn"><a name="__eq__" />bool QModelIndex.__eq__ (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__ge__" />bool QModelIndex.__ge__ (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__hash__" />int QModelIndex.__hash__ (<i>self</i>)</h3><h3 class="fn"><a name="__lt__" />bool QModelIndex.__lt__ (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__ne__" />bool QModelIndex.__ne__ (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>other</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>